package kr.couponplay.android.support;

import kr.couponplay.android.Constants;
import android.content.Context;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationManager;
import android.util.Log;

public class LocationUtils {
	public static Location getMyLocation(Context context) {
		try {
			Criteria criteria = new Criteria();
			criteria.setAccuracy(Criteria.NO_REQUIREMENT);
			criteria.setPowerRequirement(Criteria.NO_REQUIREMENT);
			criteria.setAltitudeRequired(false);
			criteria.setCostAllowed(false);
	
			LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
			String provider = locationManager.getBestProvider(criteria, true);
			Location location = locationManager.getLastKnownLocation(provider);
			return location;
		} catch (Exception e) {
			Log.e(Constants.TAG, e.getMessage(), e);
			return null;
		}
	}
}
